<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1">
<jsp:directive.page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" />
<jsp:directive.page import="java.util.ArrayList, java.util.Iterator, cult.ticketing.bean.*" />
<jsp:output omit-xml-declaration="no" doctype-root-element="html" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" />

<jsp:text><![CDATA[
<script type="text/javascript">
    function authenticate() {
        document.getElementById("pendingRefund").decision.value = "authenticate";
        document.getElementById("pendingRefund").submit();
    }

    function reject() {
        document.getElementById("pendingRefund").decision.value = "reject";
        document.getElementById("pendingRefund").submit();
    }
</script>
    
<form name="pendingRefund" id="pendingRefund" method="post" action="]]></jsp:text><jsp:expression>request.getContextPath()</jsp:expression><jsp:text><![CDATA[/index.do">
    <input type="hidden" name="todo" id="todo" value="authenticateRefund" />
    <input type="hidden" name="decision" id="decision" value="" />

    <table class="record">
    <tbody>]]></jsp:text>
    <jsp:scriptlet>
      ArrayList&lt;PurchaseRecord&gt; purchaseRecords = (ArrayList&lt;PurchaseRecord&gt;)request.getAttribute("purchaseRecords");
      ArrayList&lt;ScheduleItem&gt; scheduleItems = (ArrayList&lt;ScheduleItem&gt;)request.getAttribute("scheduleItems");
      ArrayList&lt;Movie&gt; movies = (ArrayList&lt;Movie&gt;)request.getAttribute("movies");

      Iterator&lt;PurchaseRecord&gt; it = purchaseRecords.iterator();
      while (it.hasNext() != false) {
        pageContext.setAttribute("purchaseRecord", (PurchaseRecord)it.next());
        pageContext.setAttribute("scheduleItem", (ScheduleItem)(scheduleItems.iterator().next()));
        pageContext.setAttribute("movie", (Movie)(movies.iterator().next()));
    </jsp:scriptlet>
    <jsp:useBean id="scheduleItem" type="cult.ticketing.bean.ScheduleItem" scope="page" />
    <jsp:useBean id="movie" type="cult.ticketing.bean.Movie" scope="page" />
    <jsp:useBean id="purchaseRecord" type="cult.ticketing.bean.PurchaseRecord" scope="page" />
<!--id	member_id	email	scheduleItem_id	seat_index	refund_status	purchase_time-->
    <jsp:text><![CDATA[
        <tr>
            <td>
                <input type="radio" name="purchaseRecordId" value="]]></jsp:text><jsp:getProperty name="purchaseRecord" property="id" /><jsp:text><![CDATA[" />
            </td>

            <td>]]></jsp:text>
            <jsp:getProperty name="movie" property="title" />
            <jsp:text><![CDATA[</td>

            <td>]]></jsp:text>
            <jsp:getProperty name="scheduleItem" property="houseId" />
            <jsp:text><![CDATA[</td>

            <td>]]></jsp:text>
            <jsp:getProperty name="scheduleItem" property="showTime" />
            <jsp:text><![CDATA[</td>

            <td> HKD]]></jsp:text>
            <jsp:getProperty name="scheduleItem" property="price" />
            <jsp:text><![CDATA[</td>

            <td>]]></jsp:text>
            <jsp:getProperty name="purchaseRecord" property="seatIndex" />
            <jsp:text><![CDATA[</td>

            <td>]]></jsp:text>
            <jsp:getProperty name="purchaseRecord" property="purchaseTime" />
            <jsp:text><![CDATA[</td>
        </tr>]]></jsp:text>

        <jsp:scriptlet>
            pageContext.removeAttribute("scheduleItem");
            pageContext.removeAttribute("movie");
            pageContext.removeAttribute("purchaseRecord");

        }
        </jsp:scriptlet>
        <jsp:text><![CDATA[</tbody>
        <tfoot>
                <input type="button" value="Authenticate" onclick="authenticate();" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/>
                <input type="button" value="Reject" onclick="reject();" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/>

        </tfoot>

    </table>

</form>]]></jsp:text>
</jsp:root>